import Vue from 'vue';
import VueRouter from 'vue-router';
import Film from '../views/Film/Film.vue';
import Cinema from '../views/Cinema/Cinema.vue';
import News from '../views/News/News.vue';
import Center from '../views/UserCenter/Center.vue';
import City from '../views/CityLocation/CityLocation.vue';
import Login from '../views/Login/Login.vue';

Vue.use(VueRouter);
//解决多次点击报错
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err);
};
const routes = [
  // 默认跳转到首页
  {
    path: '/',
    redirect: '/film',
  },
  {
    // 跳转首页电影
    path: '/film',
    name: 'film',
    component: Film,
  },
  {
    // 跳转影院
    path: '/cinema',
    name: 'cinema',
    component: Cinema,
  },
  {
    // 跳转资讯
    path: '/news',
    name: 'news',
    component: News,
  },
  {
    // 跳转我的
    path: '/center',
    name: 'center',
    component: Center,
  },
  {
    // 跳转城市定位页面
    path: '/city',
    name: 'city',
    component: City,
  },
  {
    // 跳转登陆页面
    path: '/login',
    name: 'login',
    component: Login,
  },
  {
    // 跳转影院详情页
    path: '/cinema/:id',
    name: 'cinemaSchedule',
    component: () => import('../components/Cinema/CinemaSchedule.vue'),
    children: [
      {
        // 跳转到电影购票页面
        path: 'id',
        name: 'filmBuy',
        redirect: 'filmBuyTicket',
      },
    ],
  },
  {
    // 跳转影院搜索页
    path: '/cinemaList',
    name: 'cinemaList',
    component: () => import('../components/Cinema/CinemaList.vue'),
  },
  {
    // 跳转影院介绍页
    path: '/cinemaInfo/:id',
    name: 'cinemaInfo',
    component: () => import('../components/Cinema/CinemaInfo.vue'),
  },
  {
    // 跳转电影的详情页
    path: '/film/:id',
    name: 'filmDetail',
    component: () => import('../components/Film/FilmDetails.vue'),
    // children:[
    //   {
    //     path: 'cinemas',
    //     // name:'filmCinemas',
    //     component:()=>import('../components/Film/FilmCinemaList.vue'),
    //   }
    // ]
  },
  {
    //跳转电影的影院页

    path: '/film/:id/cinemas',
    name: 'filmCinemas',
    component: () => import('../components/Film/FilmCinemaList.vue'),
  },

  {
    // 跳转到电影购票页面
    path: '/cinema/:filmid/:id',
    name: 'filmBuyTicket',
    component: () => import('../components/BuyTicket/BuyTicket.vue'),
  },
  //跳转电影确认订单页面
  {
    // path: '/cinema/:orderId/:id',
    path: '/filmOrder',
    name: 'filmOrder',
    component: () => import('../components/FilmOrder/FilmOrder.vue'),
  },
  {
    path: '/personalInfo',
    name: 'personalInfo',
    component: () => import('../views/Login/PersonalInfo.vue'),
  },

  {
    path: '*',
    name: 'notFound',
    component: () => import('../components/NotFound/NotFound.vue'),
  },
];

const router = new VueRouter({
  routes,
});

export default router;
